<?python
    from mnemoply.common_knowledge import day_captions
    from mnemoply.utils import format_date
?>

<root xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude">
    <xi:include href="rds.html" />

<report>
    <header />

    <pages>

        <page py:for="group in [model.Group.get(x) for x in ids]">

            <groupName py:content="group.name" />
            <teacherName py:content="group.teacher.title" />
            <totalLessons py:content="len(group.getLessons())" />
            <totalLessonsHours py:content="len(group.getLessons()) * group.lessonPeriod" />

            <schedule>
                <lesson py:for="lesson in group.schedule">
                    <office py:content="group.office.title" />
                    <day py:content="day_captions[lesson.dayOfWeek]" />
                    <startTime py:content="'%02d:%02d' % (lesson.startTimeHour, lesson.startTimeMinute)" />
                    <period py:content="group.lessonPeriod" />
                    <classroomNumber py:content="lesson.classroom.roomNumber" />
                </lesson>
            </schedule>

            <plan>
                <topic py:for="topic in group.gtopics">
                    <?python lessons_info = topic.getLessonsInfo() ?>

                    <ordinal py:content="topic.ordinal" />
                    <name py:content="topic.title" />
                    <hours py:content="topic.hours" />
                    <lessons py:content="lessons_info.lessons" />
                    <beginDate py:content="format_date(lessons_info.start_date) and format_date(lessons_info.start_date) or '-'" />
                    <endDate py:content="format_date(lessons_info.end_date) and format_date(lessons_info.end_date) or '-'" />
                    <comment py:content="topic.comment" />
                    <testType py:content="topic.topic.finalTest.name" />
                </topic>
            </plan>
        </page>

    </pages>
</report>

</root>
